﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CubicFWNet.Data
{
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public class DecimalPrecisionAttribute : System.Attribute
    {
        public byte Precision = 18;
        public byte Scale = 2;

        public DecimalPrecisionAttribute(byte precision = 18, byte scale = 2)
        {
            Precision = precision;
            Scale = scale;
            if (Precision < 1 || Precision > 38)
            {
                throw new Exception("精度必须在1和38之间.");
            }
            if (Scale < 1 || Scale > 38)
            {
                throw new Exception("刻度必须在1和38之间.");
            }
        }
    }

}
